package com.hl.controller;


import com.hl.domain.SearchQuestion;
import com.hl.service.SearchQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/search/questions")
public class SearchQuestionController {
    @Autowired
    private SearchQuestionService searchQuestionService;

    @GetMapping("/getQuestions")
    public ResponseEntity<Map<String, Object>> searchQuestions(@RequestParam String query) {
        List<SearchQuestion> questions = searchQuestionService.searchQuestions(query);
        Map<String, Object> response = new HashMap<>();
        response.put("questions", questions);
        return ResponseEntity.ok(response);

    }
}
